<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>后台管理系统</title>
        <meta name="author" content="BaiYY"/>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
        <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
    </head>
<body>
    <div class="right-sidebar" style="max-width: 1200px;">
        <ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
            <li role="presentation" class="active"><a href="onLinePay.html">在线充值</a></li>
            <li role="presentation"><a href="onLinePayDetail.html">在线充值查询</a></li>
        </ul>
        <section class="table-responsive">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>游戏ID</th>
                    <th>支付金额</th>
                    <th>支付状态</th>
                    <th>商品编号</th>
                    <th>支付时间</th>
                </tr>
                </thead>
                <tbody id="dataList"></tbody>
            </table>
        </section>
        <div id="playerPage">
            <a href="javascript:void(0)" id="prev">上一页</a>
            <a href="javascript:void(0)" id="page"></a>
            <a href="javascript:void(0)" id="next">下一页</a>
            <span>一共</span>
            <a href="javascript:void(0)" id="totalPage"></a>
            <span>页</span>
        </div>
        <div style="margin: 10px auto;" ><a href="{:U('Admin/Main/expPlayer')}" class="btn btn-primary">全部导出excel</a></div>
    </div>
    <script type="text/javascript">
        $(function () {
            $.ajax({
                type:'get',
                url:"{:U('Admin/Main/onLinePayList')}",
                success: function (data) {
//                    console.log(data);
                    var count = Math.ceil(data.count/10);
                    if(data != 'error') {
                        var str = '';
                        var state = '';
                        for(var i=0;i<data.arr.length;++i) {
                            if(data.arr[i].status == 0) {
                                state = '失败';
                            }else if(data.arr[i].status == 1) {
                                state = '成功';
                            }
                            str += "<tr><td><input type='hidden' value='"+data.arr[i].time+"'/>"+data.arr[i].uid+"</td><td>"+data.arr[i].money+"</td><td>"+state+"</td><td>"+data.arr[i].item+"</td><td class='atime' >"+getLocalTime(data.arr[i].time/1000)+"</td></tr>";
                        }
                        $("#dataList").html(str);
                        $("#totalPage").text(count);
                        $("#page").text(1);
                    }else{
                        $("#dataList").html("暂时没有数据");
                    }
                }
            })
        })
        $("#prev").on("click",function (ev) {
            var page = $.trim($("#page").text());
            var start = $("#dataList tr:first").find("input").val();
//            console.log(start);
            var action = -1;
            if(page == 1) {
                page = 1;
                return false;
            }else if($("#page").text() > 1) {
                page = page - 1;
            }
            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/onLinePayList')}",
                dataType:"text",
                async:false,
                data:{"start":start,"action":action,"page":page},
                success: function (data) {
//                    console.log(data);
                    data = JSON.parse(data);
                    if(data != 'error') {
                        var str = '';
                        var state = '';
                        for(var i=0;i<data.arr.length;++i) {
                            if(data.arr[i].status == 0) {
                                state = '失败';
                            }else if(data.arr[i].status == 1) {
                                state = '成功';
                            }
                            str += "<tr><td><input type='hidden' value='"+data.arr[i].time+"'/>"+data.arr[i].uid+"</td><td>"+data.arr[i].money+"</td><td>"+state+"</td><td>"+data.arr[i].item+"</td><td class='atime'>"+getLocalTime(data.arr[i].time/1000)+"</td></tr>";
                        }
                        $("#dataList").html(str);
                        $("#page").text(page);
                    }else{
                        $("#dataList").html("暂时没有数据");
                    }
                }
            })
        })
        
        $("#next").on("click",function (ev) {
            var page = $.trim($("#page").text());
            var start = $("#dataList tr:last").find("input").val();
            var action = 1;

            page = ++page;
            var totalPage = $.trim($("#totalPage").text())/1;
            if(page > totalPage) {
                return false;
            }
            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/onLinePayList')}",
                async:false,
                dataType:"text",
                data:{"start":start,"action":action,"page":page},
                success: function (data) {
//                    console.log(data);
                    data = JSON.parse(data);
                    if(data != 'error') {
                        var str = '';
                        var state = '';
                        for(var i=0;i<data.arr.length;++i) {
                            if(data.arr[i].status == 0) {
                                state = '失败';
                            }else if(data.arr[i].status == 1) {
                                state = '成功';
                            }
                            str += "<tr><td><input type='hidden' value='"+data.arr[i].time+"'/>"+data.arr[i].uid+"</td><td>"+data.arr[i].money+"</td><td>"+state+"</td><td>"+data.arr[i].item+"</td><td class='atime'>"+getLocalTime(data.arr[i].time/1000)+"</td></tr>";
                        }
                        $("#dataList").html(str);
                        $("#page").text(page);
                    }else{
                        $("#dataList").html("暂时没有数据");
                    }
                }
            })
        })
    </script>
</body>
</html>